package com.seal.comm;

import java.util.Locale;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.seal.action.BaseAction;

public class ChangeLanguageAction extends BaseAction {

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public String execute() {
		Locale locale = Locale.getDefault();  
		HttpSession session = ServletActionContext.getRequest().getSession(); 
		if (null != parameters.get("lan")) {
			String[] strArr = (String[]) parameters.get("lan");
			if(strArr !=null && strArr.length>0){
				String lan=strArr[0];
				if(lan.equalsIgnoreCase("cn")){
					locale = Locale.CHINA;
				}else if(lan.equalsIgnoreCase("en")){
					locale = Locale.ENGLISH;
				}
			}
		}
		//this.setSessionAttr(Globals.LOCALE_KEY, Locale.CHINA);
		//this.ServletRequest.getSession().setAttribute(Globals.LOCALE_KEY, Locale.CHINA);
		//ServletActionContext.getContext().setLocale(Locale.CHINA);
		//Constants.WW_TRANS_I18N_LOCALE;
		session.setAttribute("WW_TRANS_I18N_LOCALE", locale);
		return SUCCESS;
	}
}
